#include <iostream>
#include "contacts.pb.h"

int main()
{
    std::string str;
    {
        contacts::PeopleInfo people;
        people.set_name("张三");
        people.set_age(20);
        if (!people.SerializeToString(&str))
        {
            std::cerr << "序列化联系人失败" << std::endl;
            return -1;
        }
        std::cout << str << std::endl;
    }
    contacts::PeopleInfo people;
    if (!people.ParseFromString(str))
    {
        std::cerr << "序列化联系人失败" << std::endl;
            return -1;
    }
    std::cout << people.age() << " " << people.name() << std::endl;
    return 0;
}